package com.heima.apis.article.fallback;

import com.heima.apis.article.ArticleFeignClient;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ArticleFeignClientFallback implements FallbackFactory<ArticleFeignClient> {
    @Override
    public ArticleFeignClient create(Throwable throwable) {
        return new ArticleFeignClient() {
            @Override
            public ResponseResult<Long> save(ArticleDto dto) {
                log.info("调用文章微服务发布文章出现问题");
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR,"调用文章微服务发布文章出现问题");
            }
        };
    }
}
